/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.uefs.cedoc.controle.comarca;

import br.uefs.cedoc.db.comarca.DBComarca;

/**
 *
 * @author suporte
 */


import br.uefs.cedoc.controle.*;
import br.uefs.cedoc.db.exception.DBConnectionException;
import javax.servlet.*;
import javax.servlet.http.*;
import br.uefs.cedoc.db.*;
import br.uefs.cedoc.db.comarca.DBComarca;
import br.uefs.cedoc.entidades.*;
import java.sql.SQLException;
  
public class GetComarcaCommand implements Command {
  private String next;

  public GetComarcaCommand(String next) {
    this.next = next;
  }

    public String execute(HttpServletRequest req)
    throws CommandException {
        try {
            
            DBComarca dbcomarca = new DBComarca();
            ComarcaBean comarca = new ComarcaBean();            
            //comarca.setIdcomarca();
            int id = Integer.parseInt(req.getParameter("id"));
            comarca = dbcomarca.listaComarca(id);
            //System.out.println("deletada = "+ comarca.getIdcomarca()+ "N= "+comarca.getComarca());
            req.setAttribute("comarca",comarca);

            } catch (SQLException ex) {
                ex.printStackTrace();
            } catch (DBConnectionException ex) {
                ex.printStackTrace();
            }

            req.setAttribute("status.msg", "tetes");
            
            return next;

    }
}


